package com.carworld.controller;

import com.alibaba.fastjson.JSONObject;
import com.carworld.config.BaseController;
import com.carworld.model.SysOffice;
import com.carworld.model.SysUser;

public class SysOfficeController extends BaseController {

	public void getSysOfficeInfo() {
		SysUser user = SysUser.dao.findByIdInCache(getUserCookie());
		Object shop = null;
		if (user != null && !"1".equals(user.getUserIsVerificated())) {
			System.out.println("用户不是会员，没有所属门店");
			shop = SysOffice.dao.findShopInCache("a6134faf9a844fe0ae006c7bd1d9a6d5");
		} else if (user != null &&user.getCompanyId() != null) {
			System.out.println("用户是会员，所属的门店id：" + user.getCompanyId());
			shop = SysOffice.dao.findShopInCache(user.getCompanyId());
		}else if(user != null &&user.getCompanyId() == null){
			//无对应门店用户默认预约显示末德
			shop = SysOffice.dao.findShopInCache("a6134faf9a844fe0ae006c7bd1d9a6d5");
		}else {
			System.out.println("用户不存在");
		}

		JSONObject jsonObject = getJsonObject();
		jsonObject.put("page", shop);
		jsonObject.put("user", user);
		renderJson(jsonObject);

	}

}
